package com.nioserver.propertys;

import com.nioserver.linklayer.Socket;
import org.luaj.vm2.LuaValue;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class RoleMaps {

    private static Integer index = 0;
    private static Map<Integer,Role> maps =
            Collections.synchronizedMap(new HashMap<>());

    public static Role getRole(int id){
        return maps.get(id);
    }
    public static Role genRole(int id, Socket socket){
        maps.put(id,new Role(id,socket));

        return maps.get(id);
    }
    public static void deRole(int id){
        maps.remove(id);
    }
    public static int generateId(){
        index+=1;
        return index-1;
    }
}
